package com.zy.ivideo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@ApiModel(value = "评论实体类",description = "评论实体类")
@Table(name = "b_comment")
public class CommentEntity {
    /**
     * 主键
     */
    @ApiModelProperty(value = "主键id",position = 16,example = "0")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 数据类型 0-simplevideo 1-multitypevideo
     */
    @ApiModelProperty(value = "数据类型 0-simplevideo 1-multitypevideo",position = 16,example = "0")
    @Column(nullable = false,length = 2)
    private int datatype;

    @ApiModelProperty(value = "资源id 短视频对应-item_id字段 放映厅对应-albumid字段",position = 16,example = "6992028792893997581")
    @Column(name = "itemid",length = 100,columnDefinition = "COMMENT '资源id'")
    private String itemid;

    @ApiModelProperty(value = "评论内容",position = 16,example = "很喜欢这个观点")
    @Column(name = "content",length = 200,columnDefinition = "COMMENT '评论内容'")
    private String content;

    @ApiModelProperty(value = "用户id",position = 16,example = "0")
    @Column(name = "userid",columnDefinition = "COMMENT '用户id'")
    private int userid;

    @ApiModelProperty(value = "用户昵称",position = 16,example = "小红")
    @Column(name = "nickname",length = 50,columnDefinition = "COMMENT '用户昵称'")
    private String nickname;

    @Column(name = "userlogo",length = 200,columnDefinition = "COMMENT '用户头像'")
    private String userlogo;

    @ApiModelProperty(value = "创建时间",position = 16,example = "2024-01-01 00:00::00")
    @CreatedDate
    @Column()
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createtime;

    @ApiModelProperty(value = "回复数量",position = 16,example = "20")
    @Column(name = "replytotal",length = 5,columnDefinition = "COMMENT '回复数量'")
    private int replytotal;

    @ApiModelProperty(value = "点赞数量",position = 16,example = "200")
    @Column(name = "agreenum",length = 5,columnDefinition = "COMMENT '点赞数量'")
    private int agreenum;

    @Transient
    private List<ReplyEntity> replyList;
}
